//
//  ClassAttendance.m
//  SchoolTask
//
//  Created by feel on 16/8/25.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "ClassAttendance.h"
#define kScreenW [UIScreen mainScreen].bounds.size.width
#define kScreenH [UIScreen mainScreen].bounds.size.height


@interface ClassAttendance ()

@property (nonatomic,retain) UILabel  *classNameLb;    //课程
@property (nonatomic,retain) UILabel  *attendance;     //正常考勤
@property (nonatomic,retain) UILabel  *late;           //迟到
@property (nonatomic,retain) UILabel  *leave;          //早退
@property (nonatomic,retain) UILabel  *askLeave;       //请假
@property (nonatomic,retain) UILabel  *crunk;          //旷课

@property (nonatomic,retain) UILabel  *classNameLbVule;    //课程值
@property (nonatomic,retain) UILabel  *attendanceVule;     //正常考勤值
@property (nonatomic,retain) UILabel  *lateVule;           //迟到值
@property (nonatomic,retain) UILabel  *leaveVule;          //早退值
@property (nonatomic,retain) UILabel  *askLeaveVule;       //请假值
@property (nonatomic,retain) UILabel  *crunkVule;          //旷课值

@property (nonatomic,retain) UILabel  *lineLabel;
@end
@implementation ClassAttendance

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.frame = [UIScreen mainScreen].bounds;
        [self setLabel];
        [self setButton];
    }
    return self;
}

- (void)setLabel {
    
    _classNameLb = [[UILabel alloc]initWithFrame:CGRectMake(20, 80, 100, 50)];
    _crunk       = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-50, 80, 25, 30)];
    _crunkVule   = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-20, 80, 20, 30)];
    _askLeave    = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-90, 80, 25, 30)];
    _askLeaveVule = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-60, 80, 20, 30)];
    _leaveVule   = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 100, 80, 20, 30)];
    _leave       = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 130, 80, 25, 30)];
    _lateVule    = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 140, 80, 20, 30)];
    _late        = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 170, 80, 25, 30)];
    _attendanceVule = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 180, 80, 20, 30)];
    _attendance  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 210, 80, 25, 30)];
    
    //值左对其
    _crunkVule.textAlignment      = 0;
    _askLeaveVule.textAlignment   = 0;
    _lateVule.textAlignment       = 0;
    _attendanceVule.textAlignment = 0;
    _leaveVule.textAlignment      = 0;
    
    //表示符右对齐
    _crunk.textAlignment      = 2;
    _askLeave.textAlignment   = 2;
    _late.textAlignment       = 2;
    _attendance.textAlignment = 2;
    _leave.textAlignment      = 2;

    //假数据
    _classNameLb.text = @"语文";
    _crunk.text      = @"旷课:";
    _askLeave.text   = @"请假:";
    _askLeaveVule.text = @"3";
    _crunkVule.text  = @"5";
    _leave.text      = @"早退:";
    _leaveVule.text  = @"55";
    _late.text       = @"迟到:";
    _lateVule.text   = @"77";
    _attendance.text = @"正常:";
    _attendanceVule.text = @"10";
    
    //更改字体大小
     _classNameLb.font = [UIFont boldSystemFontOfSize:30];
    _crunk.font     = [UIFont systemFontOfSize:10];
    _askLeave.font  = [UIFont systemFontOfSize:10];
    _crunkVule.font = [UIFont systemFontOfSize:10];
    _crunk.font     = [UIFont systemFontOfSize:10];
    _leaveVule.font = [UIFont systemFontOfSize:10];
    _leave.font     = [UIFont systemFontOfSize:10];
    _late.font      = [UIFont systemFontOfSize:10];
    _lateVule.font  = [UIFont systemFontOfSize:10];
    _attendance.font     = [UIFont systemFontOfSize:10];
    _attendanceVule.font = [UIFont systemFontOfSize:10];
    _askLeaveVule.font   = [UIFont systemFontOfSize:10];


    _classNameLb.textColor = [UIColor colorWithRed:250/255.0 green:140/255.0 blue:0 alpha:1];
    _crunk.textColor       = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _crunkVule.textColor   = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _askLeave.textColor     = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _askLeaveVule.textColor = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _leaveVule.textColor    = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _leave.textColor        = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _lateVule.textColor     = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _late.textColor         = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _attendanceVule.textColor = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    _attendance.textColor     = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];

    
    [self addSubview:_classNameLb];
    [self addSubview:_crunk];
    [self addSubview:_crunkVule];
    [self addSubview:_askLeaveVule];
    [self addSubview:_askLeave];
    [self addSubview:_leave];
    [self addSubview:_leaveVule];
    [self addSubview:_lateVule];
    [self addSubview:_late];
    [self addSubview:_attendanceVule];
    [self addSubview:_attendance];
}


//设置按钮
- (void)setButton {
    
    NSArray *array      = [NSArray arrayWithObjects:@"上课时间",@"签到",@"早退", nil];
    NSInteger buttonTag = 1000;
    CGFloat w           = [UIScreen mainScreen].bounds.size.width/3;
    
    //设置底部移动的黄线
    _lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, w, 2)];
    _lineLabel.backgroundColor = [UIColor colorWithRed:250/255.0 green:190/255.0 blue:150/255.0 alpha:1];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, w*3, 2)];
    label.backgroundColor = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    
    //创建button 5个
    for (NSInteger i = 0; i < array.count; i++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame     = CGRectMake(0 + w * i, 150 , w, 50);
        [button setTitle:array[i] forState:UIControlStateNormal];
        
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [button setTitleColor:[UIColor colorWithRed:130/255.0 green:130/255.0 blue:130/255.0 alpha:1]forState:UIControlStateNormal];
        button.tag = buttonTag;
        button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
        
        
        buttonTag ++;
        [self addSubview:button];
        [self addSubview:label];
        [self addSubview:_lineLabel];
    }
    
}
- (void)buttonAction:(UIButton *)button {
    
    CGFloat w = [UIScreen mainScreen].bounds.size.width/3;
    CGFloat i = button.tag - 1000;
    _lineLabel.frame = CGRectMake(0 + w * i, 200 , w, 2);
    
    NSLog(@"button");
    
    if (button.tag == 1000) {
        
    }
}




@end
